<!DOCTYPE html>
<title>Navigating iframe loading='lazy' before it is loaded: form submit</title>
<iframe name="iframe" src="support/blank.htm?src" loading="lazy" hidden></iframe>
<form action="support/blank.htm" target="iframe"></form>
<script>
const iframe = document.querySelector('iframe');
const iframeLoaded = new Promise(resolve => {
  iframe.onload = resolve;
});
const form = document.querySelector('form');
form.submit();
iframe.hidden = false;
</script>
<!-- Loading testharness.js here is intentional to reproduce a bug in WebKit. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({single_test: true});
iframeLoaded.then(() => {
  // Need a timeout to detect failure when there are two navigations.
  step_timeout(() => {
    // The "?" in the URL is there because the default method is "GET"
    // and the form data (empty here) is populated into the query.
    assert_equals(iframe.contentWindow.location.href, new URL("support/blank.htm?", location.href).href);
    done();
  }, 1000);
});
</script>
